<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>通用Maven项目登录</title>
<link type="text/css" rel="stylesheet" href="${pageContext.request.contextPath}/Resources/css/base.css" />
<script type="text/javascript" src="${pageContext.request.contextPath }/jquery-easyui-1.3.4/jquery.min.js"></script>

<script type="text/javascript">
	var loginSuccessUrl = "${pageContext.request.contextPath }/transfer/default";

	$(document).ready(function() {
		loadLoginInfoFromCookie();

		bindEvent();
	});

	function bindEvent() {
		$("#p-loginForm").submit(function() {
			loginIn();

			return false;
		});
	}

	function loadLoginInfoFromCookie() {
		/* var oldLoginId = $.cookie("OPEN_REMEMBER_ME");
		
		if(oldLoginId){
			$("loginId").val(oldLoginId);
		} */
	}

	function loginIn() {
		if (checkLoginInfo() != true)
			return;

		$.post('${pageContext.request.contextPath }/ajax/login', $(
				"#p-loginForm").serialize(), function(data, textStatus, jqXHR) {
			if (textStatus == "error") 
			{
				showErrorMsg("网络异常，请稍后重试！");
			} 
			else 
			{
				if (data.loginStatus == "success") 
				{
					location.href = loginSuccessUrl;
				}
				else 
				{
					showErrorMsg("用户名密码错误，请重试！");
				}
			}
		});
	}

	function checkLoginInfo() {
		var loginId = $("#loginId").val();
		var password = $("#password").val();

		if (loginId == null || loginId == "") {
			showErrorMsg("请填写登录号！");
			return false;
		}

		if (password == null || password == "") {
			showErrorMsg("请填写密码！");
			return false;
		}

		return true;
	}

	function showErrorMsg(msg) {
		if (msg == null || msg == "") {
			$(".w-error-tip").text("").css("display", "none");
		} else {
			$(".w-error-tip").text(msg).css("display", "block");
		}
	}
</script>

</head>
<body>
	<div class="g-main m-open-topbar">
		<div class="topContent g-wraper960 f-clear">
			<a href="">
				<h1>简易.开放平台</h1>
			</a>
			<div class="registration">
				"还没有简易开放平台账号？" <a class="login" target="_blank" href="">安装注册</a>
			</div>
		</div>
	</div>
	<div class="g-main m-big-banner f-clear">
		<div class="g-wraper960 f-clear form-wraper" style="position: relative; height: 100%;">
			<div class="m-login-panel f-trans" id="J-user-actPanel" style="margin-top: -200px;">
				<h2 class="f-yahei">简易开放平台，简单易用</h2>
				<form id= "p-loginForm" class="m-login-form f-clear">
					<div class="w-error-tip f-tcf j-error-tip f-trans" style="display: none; position: absolute;">请输入密码！</div>
					<div class="title">登录管理中心</div>
					<div class="filed">
						<label class="filed-left" for="phone">帐&nbsp;号：</label> 
						<input id="loginId" name="user.loginId" type="text" placeholder="手机号/简易信号" />
					</div>
					<div class="filed">
						<label class="filed-left" for="password">密&nbsp;码：</label> 
						<input id="password" name="user.password" type="password" />
					</div>
					<div class="rememberMe-line">
						<input id="rememberMe" name="rememberMe" type="checkbox" value="true" /> 
						<label for="rememberMe">记住帐号</label>
					</div>
					<div>
						<button class="w-button" id="p-loginForm-submit" type="submit">登&nbsp;录</button>
					</div>
				</form>
			</div>
		</div>
	</div>
	<div class="g-open-footer ">
		<div class="footer-wrap">
			<p class="foo-links">
				<a class="foo-item" href="">简易开放平台首页</a> <a class="foo-item" href="">简易公司简介</a> <a class="foo-item" href="">服务条款</a> <a class="foo-item" href="">开发者协议</a>
				<a class="foo-item" href="">联系我们</a>
			</p>
			<p class="foo-copyright">简易公司 © 粤ICP备53021234号</p>
		</div>
	</div>
</body>
</html>